//
//  DHAchorFirstTableViewCell.m
//  Moment
//
//  Created by dllo on 15/12/29.
//  Copyright © 2015年 片刻. All rights reserved.
//

#import "DHAchorFirstTableViewCell.h"

@implementation DHAchorFirstTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews{
    _firstTitleLable = [UILabel new];
    [self.contentView addSubview:_firstTitleLable];
    [_firstTitleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(SCREEN_WIDTH * 0.05));
        make.left.equalTo(@(SCREEN_WIDTH * 0.05));
        make.width.equalTo(@(SCREEN_WIDTH * 0.1));
        make.height.equalTo(@(SCREEN_WIDTH * 0.08));
    }];

    _firstImageView = [UIImageView new];
    [self.contentView addSubview:_firstImageView];
    [_firstImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_firstTitleLable.mas_top);
        make.left.equalTo(_firstTitleLable.mas_right).offset(SCREEN_WIDTH * 0.03);
        make.width.and.height.equalTo(_firstTitleLable.mas_height);
    }];
    _firstImageView.layer.cornerRadius = SCREEN_WIDTH * 0.08 / 2;
    _firstImageView.layer.masksToBounds = YES;
    _firstImageView.layer.borderWidth = 0.1;
    _firstImageView.layer.borderColor = [UIColor blackColor].CGColor;
    _firstNameLabel = [UILabel new];
    [self.contentView addSubview:_firstNameLabel];
    [_firstNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_firstTitleLable.mas_top);
        make.left.equalTo(_firstImageView.mas_right).offset(SCREEN_WIDTH * 0.01);
        make.width.equalTo(_firstTitleLable.mas_width).multipliedBy(3);
        make.height.equalTo(_firstTitleLable.mas_height);
    }];


    
    _secondeTitleLabel = [UILabel new];
    [self.contentView addSubview:_secondeTitleLabel];
    [_secondeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_firstTitleLable.mas_bottom).offset(SCREEN_HEIGHT * 0.05);
        make.left.equalTo(_firstTitleLable.mas_left);
        make.width.equalTo(_firstTitleLable.mas_width);
        make.height.equalTo(_firstTitleLable.mas_height);
    }];

    
    _secondeImageView = [UIImageView new];
    [self.contentView addSubview:_secondeImageView];
    [_secondeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_secondeTitleLabel.mas_top);
        make.left.equalTo(_firstImageView.mas_left);
        make.size.equalTo(_firstImageView);
    }];
    _secondeImageView.layer.cornerRadius = SCREEN_WIDTH * 0.08 / 2;
    _secondeImageView.layer.masksToBounds = YES;
    _secondeImageView.layer.borderWidth = 0.1;
    _secondeImageView.layer.borderColor = [UIColor blackColor].CGColor;
    
    _secondNameLabel = [UILabel new];
    [self.contentView addSubview:_secondNameLabel];
    [_secondNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_secondeTitleLabel.mas_top);
        make.left.equalTo(_firstNameLabel.mas_left);
        make.size.equalTo(_firstNameLabel);
    }];

    _thirdLabel = [UILabel new];
    [self.contentView addSubview:_thirdLabel];
    [_thirdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_firstTitleLable.mas_left);
        make.top.equalTo(_secondeTitleLabel.mas_bottom).offset(SCREEN_HEIGHT * 0.05);
        make.width.equalTo(_firstTitleLable.mas_width).multipliedBy(1.6);
        make.height.equalTo(_firstTitleLable.mas_height);
        
    }];

    _thirdNameLabel = [UILabel new];
    [self.contentView addSubview:_thirdNameLabel];
    [_thirdNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_thirdLabel.mas_bottom);
        make.top.equalTo(_thirdLabel);
        make.left.equalTo(_thirdLabel.mas_right).offset(SCREEN_HEIGHT * 0.01);
        make.width.equalTo(_thirdLabel.mas_width).multipliedBy(2);
     }];

    
}
-(void)setPlayerRadio:(DHREPlayeRadio *)playerRadio{
    if (_playerRadio != playerRadio) {
        _playerRadio = playerRadio;
    }
    NSLog(@"_playerRadio == %@",_playerRadio);
_firstTitleLable.text = @"主播：";
    _firstTitleLable.font = [UIFont systemFontOfSize:12];
    NSURL *firstUrl = [NSURL URLWithString:_playerRadio.userInfo.icon];
    [_firstImageView sd_setImageWithURL:firstUrl placeholderImage:PLACEHOLDER_IMAGE];
    _firstNameLabel.text = _playerRadio.userInfo.uname;
    _firstNameLabel.font = [UIFont systemFontOfSize:12];
    _secondeTitleLabel.text = @"原文:";
    _secondeTitleLabel.font = [UIFont systemFontOfSize:12];
     NSURL *secondUrl = [NSURL URLWithString:_playerRadio.authorInfo.icon];
    [_secondeImageView sd_setImageWithURL:secondUrl placeholderImage:PLACEHOLDER_IMAGE];
    _secondNameLabel.text = _playerRadio.authorInfo.uname;
    _secondNameLabel.font = [UIFont systemFontOfSize:12];
    _thirdLabel.text = @"来自电台：";
    _thirdLabel.font = [UIFont systemFontOfSize:12];
    _thirdNameLabel.text = _playerRadio.radioname;
    _thirdNameLabel.font = [UIFont systemFontOfSize:12];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
